﻿@page
@model AdminUI.Pages.SysManage.ActionLogModel
@{
    var F = Html.F();
}

@section head {
@*    <style>
        .f-grid-cell.f-grid-cell-Memo .f-grid-cell-inner {
            white-space: normal;
            word-break: break-all;
        }

    </style>*@

}

@section body {
    <f:Panel ID="Panel1" BodyPadding="5" ShowBorder="false" Layout="VBox" ShowHeader="false" IsViewPort="true">
        <Items>
            <f:Grid ID="Grid1" BoxFlex="1" ShowBorder="true" ShowHeader="false" EnableTextSelection="true" EnableColumnLines="true" EnableCheckBoxSelect="true" EnableMultiSelect="true" AllowSorting="true" AllowPaging="true" IsDatabasePaging="true"
                DataIDField="ID" DataTextField="ActionLogName" PageSize="@ViewBag.PageSize" RecordCount="@ViewBag.Total" DataSource="@ViewBag.DataSource"
                OnSort="@Url.Handler("Grid_DoAction")" OnSortFields="Panel1" SortingToolTip="true" SortingCancel="true" OnPageIndexChanged="@Url.Handler("Grid_DoAction")" OnPageIndexChangedFields="Panel1">
                <Toolbars>
                    <f:Toolbar ID="Toolbar1" ToolbarAlign="Right" ItemSpace="1">
                        <Items>
                 
                            <f:Button ID="btnDelete" IconAlign="Left" EnableDefaultState="false" IconFont="TrashO" Text="删除" OnClientClick="onDeleteClick();"></f:Button>
                            <f:ToolbarSeparator></f:ToolbarSeparator>
                            <f:Button ID="btnRefresh" IconAlign="Left" EnableDefaultState="false" IconFont="Refresh" Text="刷新" OnClientClick="onRefreshClick();"></f:Button>
                            <f:ToolbarFill ID="ToolbarFill1"></f:ToolbarFill>
                            <f:DropDownList ID="ddlCondition" SelectedValue="" Width="150">
                                <f:ListItem Text="== 请选择条件 ==" Value="" />
                                <f:ListItem Text="操作员ID" Value="UserID" />
                                <f:ListItem Text="操作类型" Value="ActionType" />
                            </f:DropDownList>
                            <f:TriggerBox ID="ttbSearch" ShowLabel="false" EmptyText="请输入搜索关键字" TriggerIcon="Search" OnTriggerClick="@Url.Handler("Grid_DoAction")" OnTriggerClickFields="Panel1"
                                      OnTriggerClickParameter1="@(new Parameter("actionType", "search", ParameterMode.String))"
                                      OnTriggerClickParameter2="@(new Parameter("searchText", "F.ui.ttbSearch.getValue()"))"
                                      OnTriggerClickParameter3="@(new Parameter("searchCondition", "F.ui.ddlCondition.getValue()"))">
                            </f:TriggerBox>
                        </Items>
                    </f:Toolbar>
                </Toolbars>
                <Columns>
                    <f:RowNumberField HeaderText="#" TextAlign="Center" />
                    <f:RenderField HeaderText="日志ID" DataField="ID" FieldType="Int" Hidden="true" Width="80" TextAlign="Center" />
                    <f:RenderField HeaderText="操作员" DataField="UserID" FieldType="Int" Width="200" RendererFunction="renderUser" />
                    <f:RenderField HeaderText="用户名" DataField="UserName" Width="100" Hidden="true" />
                    <f:RenderField HeaderText="姓名" DataField="TrueName" Width="100" Hidden="true" />
                        <f:RenderField HeaderText="类型" DataField="ActionType" Width="60" TextAlign="Center" />
                    <f:RenderField HeaderText="路径Url" DataField="ModuleUrl" Width="220" ShowToolTip="true" />
                    <f:RenderField HeaderText="客户端IP" DataField="ClientIP" Width="130" />
                    <f:RenderField HeaderText="操作时间" DataField="CreateTime" FieldType="Date" Renderer="Date" RendererArgument="yyyy-MM-dd HH:mm:ss" Width="160" TextAlign="Center" />
                    <f:RenderField HeaderText="详情" DataField="Memo" MinWidth="200" ShowToolTip="true" ExpandUnusedSpace="true" />
                </Columns>
                <PageItems>
                    <f:ToolbarSeparator></f:ToolbarSeparator>
                    <f:ToolbarText Text="每页记录数："></f:ToolbarText>
                    <f:DropDownList ID="ddlGridPageSize" Width="60" SelectedValue="@ViewBag.PageSize" OnSelectedIndexChanged="@Url.Handler("Grid_DoAction")" OnSelectedIndexChangedParameter1="@(new Parameter("actionType","changePageSize",ParameterMode.String))" OnSelectedIndexChangedFields="Panel1">
                        <Items>
                            <f:ListItem Text="10" Value="10"></f:ListItem>
                            <f:ListItem Text="20" Value="20"></f:ListItem>
                            <f:ListItem Text="30" Value="30"></f:ListItem>
                            <f:ListItem Text="50" Value="50"></f:ListItem>
                            <f:ListItem Text="100" Value="100"></f:ListItem>
                            <f:ListItem Text="200" Value="200"></f:ListItem>
                        </Items>
                    </f:DropDownList>
                </PageItems>
            </f:Grid>
        </Items>
    </f:Panel>

    <f:Window ID="Window1" IsModal="true" Hidden="true" Target="Top" EnableResize="true" EnableMaximize="true" EnableIFrame="true" Width="750" Height="500">
        @*<Listeners>
    <f:Listener Event="close" Handler="onWindowClose('refresh');"></f:Listener>
    </Listeners>*@
    </f:Window>
}

@section script {
    <script src="~/res/js/grid.js"></script>
    <script>
        /*
            //关闭弹窗后刷新当前页面
            function onWindowClose(actionType, actionParams) {
                var params = {
                    //nodeId: getNodeId()
                };

                if(actionType) params.actionType = actionType;
                if(actionParams) $.extend(params, actionParams);// 加入扩展参数

                F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1', params); // 触发后台事件
            }
        */

        function onDeleteClick(event) {
            var grid1 = F.ui.Grid1;
            if (!grid1.hasSelection()) {
                showNotify('请选择要删除的记录！');
                return;
            }

            var selectedRows = grid1.getSelectedRows();
            F.confirm({
                message: '确定要删除所选记录吗？',
                target: '_top',
                ok: function () {
                    F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1', {
                        actionType: 'delete',
                        selectedIDs: selectedRows
                    });
                }
            });
        }
        function onRefreshClick() {
            var grid1 = F.ui.Grid1;
            var selectedRows = grid1.getSelectedRows();
            F.doPostBack('@Url.Handler("Grid_DoAction")', 'Panel1', {
                actionType: 'refresh',
                selectedIDs: selectedRows
            });
        }

        // function renderTenant(value, params) {
        //     if (value > 0) {
        //         return value + "-" + params.rowData.values.TenantName;
        //     } else {
        //         return "平台系统";
        //     }
        // }

        //操作员：ID+Name
        function renderUser(value, params) {
            if (value > 0) {
                return value + "-" + params.rowData.values.UserName + "-" + params.rowData.values.TrueName;
            } else {
                return "-";
            }
        }

        function renderActionType(value, params) {
            return value;
            //switch (value) {
            //    case "insert":
            //        return "";
            //    case "":
            //        return "";
            //    case "":
            //        return "";
            //    default:
            //        return "";
            //}
        }

    </script>
}